﻿namespace Microsoft.VisualStudio.TestTools.UnitTesting
{
    using System;

    /// <summary>
    /// Specifies the code to use when building the assembly.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
    public class AssemblyBuilderCodeAttribute : Attribute
    {
        private readonly string code;
        private readonly AssemblyBuilderLanguage language;

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyBuilderCodeAttribute"/> class.
        /// </summary>
        /// <param name="code">The code.</param>
        public AssemblyBuilderCodeAttribute(string code)
            : this(AssemblyBuilderLanguage.CSharp, code)
        {
            this.code = code;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyBuilderCodeAttribute"/> class.
        /// </summary>
        /// <param name="code">The code.</param>
        public AssemblyBuilderCodeAttribute(AssemblyBuilderLanguage language, string code)
        {
            this.language = language;
            this.code = code;
        }
        #endregion Constructors

        #region Public Properties
        /// <summary>
        /// Gets the code.
        /// </summary>
        /// <value>The code.</value>
        public string Code
        {
            get { return this.code; }
        }

        /// <summary>
        /// Gets the language.
        /// </summary>
        /// <value>The language.</value>
        public AssemblyBuilderLanguage Language
        {
            get { return this.language; }
        }
        #endregion Public Properties
    }
}
